/*
* @Description: 首页-附近站点模块
* @Author: yingying.fan
* @Date: 2019-07-01 12:57:08
* @Last Modified by: yingying.fan
* @Last Modified time: 2019-07-01 12:57:08
*/
<template>
  <div>
    <!-- 标题tab -->
    <div class="tab-list-wrapper flex-h flex-ve xb_border_bottom eee">
      <div
        v-for="(item,index) in tabList"
        :key="`tab_${index}`"
        class="tab-wrapper"
        :class="[selectedIndex===index?['tab-selected','baseColorWithActive']:['tab-not-selected','baseColorInvalid']]"
        @click="selectTab(index,item)"
      >
        <p>{{item.text}}</p>
        <div class="baseBgColorNoActive"></div>
      </div>
    </div>
    <!-- 页面主要部分 -->
    <keep-alive>
      <router-view />
    </keep-alive>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      selectedIndex: -1,
      tabList: [
        { text: '附近', page: '/nearby' },
        { text: '收藏', page: '/collection' }

      ]
    }
  },
  mounted() {
    let index = 0
    this.selectTab(index, this.tabList[index])
  },
  methods: {
    selectTab(index, item) {
      if (this.selectedIndex !== index) {
        this.selectedIndex = index
        this.$router.replace(item.page)
      }
    }
  }
}
</script>

<style>
/* 标题tabbar */
.tab-list-wrapper {
  width: 656px;
  height: 100px;
  padding: 0 32px;
  font-size: 0;
}
/*tab样式*/
.tab-wrapper {
  display: inline-block;
  width: 120px;
  text-align: center;
}
/*tab未选中样式*/
.tab-not-selected {
  font-size: 16px; /*no*/
  line-height: 28px; /*no*/
}
/*tab未选中颜色*/
.baseColorInvalid {
  color: #666;
}
/*tab选中样式*/
.tab-selected {
  font-size: 20px; /*no*/
  line-height: 28px; /*no*/
}
/*tab选中样式*/
.tab-selected > div {
  width: 120px;
  height: 6px;
  position: relative;
  bottom: 2px;
}
.tab-list-wrapper > div:first-of-type {
  margin-right: 32px;
}
</style>
